<?php 

namespace app\supermanager\controller;
use app\common\traits\controller\TraitController;
/**
 * 总公司退押金类
 */
class QuitDeposit extends \think\Controller
{
	use TraitController;
	const ORDER_REFUND_ON = 102;//退款中
	const ORDER_CANCEL_STATUS = 103;//取消订单
	const ORDER_REFUND_DEPOSIT_STATUS = 202;//返还押金中
    const ORDER_REFUND_FINISH = 203;//已完成的订单
    protected function init(){
		if (!model('Managers')->checkLogin()) {
            $this->redirect('@manager/login');
            exit;
        }
		$this->model = model('QuitDeposits');
	}
	/**
	 * 取消订单等待退款的
	 */
	public function getCancelRefundOn(){
		$query = input('get.');
		$order = $this->model->getOrders(array_merge($query,['status' => self::ORDER_REFUND_ON]));
	    return view('quit_deposit/cancel_refund_on',['order'=>$order]);
	}
	
	/**
	 * 已离开订单等待退押金的
	 *
	*	public function getLeavedRefundOn(){
	*		$query = input('get.');
	*		$order = $this->model->getOrders(array_merge($query,['status' => self::ORDER_REFUND_DEPOSIT_STATUS]));
	*	    return view('quit_deposit/leaved_refund_on',['order'=>$order]);
	*	}
	*
	 */
	 
	/**
	 * 取消订单退款完成的订单信息.......................................
	 */
	public function getCancelRefundFinish(){
		$query = input('get.');
		$order = $this->model->getOrders(array_merge($query,['status' => self::ORDER_CANCEL_STATUS]));
	    return view('quit_deposit/cancel_refund_finish',['order'=>$order]);
	}
	
	/**
	 *已离开订单退款完成的订单信息.......................................
	 *
	*	public function getLeavedRefundFinish(){
	*		$query = input('get.');
	*		$order = $this->model->getOrders(array_merge($query,['status' => self::ORDER_REFUND_FINISH]));
	*	    return view('quit_deposit/leaved_refund_finish',['order'=>$order]);
	*	}
	*/
	
	/**
	 * 取消订单退款
	 */
	public function getCancelQuitDeposit(){
		$where['number'] = input('get.num');
		$where['status'] = self::ORDER_REFUND_ON;
		if($this->model->quitDeposit($where)){
			$this->success('退款成功','/QuitDeposits/cancelrefundfinish');
		}
		$this->error($this->model->getError());
	}
	
	/**
	 * 已离开订单退款押金
	 *
	*	public function getLeavedQuitDeposit(){
	*		$where['number'] = input('get.num');
	*		$where['status'] = self::ORDER_REFUND_DEPOSIT_STATUS;
	*		if($this->model->quitDeposit($where)){
	*			$this->success('退款成功','/QuitDeposits/leavedrefundfinish');
	*		}
	*		$this->error($this->model->getError());
	*	}
	*/
	
	/**
	 * 订单详情
	 */
	public function getCancelOrderRead(){
		$number = input('get.num');
		$order = model('Orders')->where(['number'=>$number])->find();
		$quit_deposit = $this->model->where(['number'=>$number])->find();
	    return view('quit_deposit/read',['order'=>$order,'quit_deposit'=>$quit_deposit]);	
	}
}






 ?>